<?php

//echo br(3); ###########################################################################################

	$TEMP->set_file(array('handle' => DIR_VIEW_DEAN . 'announcement.html'));
	
	include DIR_MODEL		. "announcementMod.php";
	include DIR_CONTROLLER	. "announcementCon.php";
	
	$ANNOUNCE 		= new WS_AnnouncementCon();
	
	
	$getListAnnouncementCount = $ANNOUNCE->getListAnnouncementCount($strAccDept);

	if( $getListAnnouncementCount > 0 ) {
		$countNum			= 20;
		$pagenum 			= $_GET["page_no"];
		$page_rows 			= $PAGINATION->numPerRow($countNum);
		$last 				= $PAGINATION->lastCeilPerRow($getListAnnouncementCount, $page_rows);
		$pagenum 			= $PAGINATION->pageNumRow($pagenum, $last); 
		$pageLimit 			= $PAGINATION->limitRow($pagenum, $page_rows);
		
		$arrBut				= array('first' 	=> '<img src="' . DIR_IMAGES . 'pagination_first.png" title="Delete" border="0" />',
									'previous' 	=> '<img src="' . DIR_IMAGES . 'pagination_prev.png" title="Delete" border="0" />',
									'next' 		=> '<img src="' . DIR_IMAGES . 'pagination_next.png" title="Delete" border="0" />',
									'last' 		=> '<img src="' . DIR_IMAGES . 'pagination_last.png" title="Delete" border="0" />',);
		$classCSS			= array('button' 	=> 'pagination-button', 'label' 	=> 'pagination-label');
		$urlGet				= array('page' 		=> $_GET['page'], 		'search' 	=> $search);
		
		if( $getListAnnouncementCount > $countNum ) {
			$pagination 	= $PAGINATION->pagination($arrBut, $pagenum, $last, $classCSS, $urlGet);
		}
	}
		
	$listAnnouncement = $ANNOUNCE->getListAnnouncement($strAccDept);
	
	
	# LSITING
	if ( !empty($listAnnouncement) ) {
		
		$TEMP->set_block('handle',  'announcements', 'announcementRow');
		$bgcolor 	= LOOPING_F0F;
		$numCount 	= 1;
		
		if ( intval($_GET['page_no']) > 1 ) {
			$countNumSub = intval($_GET['page_no']);
			$numCount += intval($_GET['page_no'] - 1) * $countNum;
		}
			
		foreach($listAnnouncement as $listAnnouncementField => $listAnnouncementValue) {
			
			if ($listAnnouncementValue['is_deleted'] == 'N') {
				$edButton = '<div class="icon-button">
									&nbsp;&nbsp;<a href="?page=PostAnnouncement&aid=' . $listAnnouncementValue['announce_idPK'] . '"><img src="' . DIR_IMAGES . 'icon/pencil.png" border="0" title="Edit"/></a>
									&nbsp;<img src="' . DIR_IMAGES . 'icon/recyclebin.png" title="Delete" border="0" onclick="popupDelete(\'' . $listAnnouncementValue['announce_idPK'] . '\', \'260\')" class="cursor-pointer"/>
									&nbsp;<img src="' . DIR_IMAGES . 'icon/view.png" border="0" title="View Profile" onclick="popupRequest(\'show\', \'ViewAnnouncement\', \'' . $strAccCourse . '\', \'390\', \'500\', \'' . $listAnnouncementValue['announce_idPK'] . '\');" class="cursor-pointer"/>
									<div class="delete-button" id="delete_button_' . $listAnnouncementValue['announce_idPK'] . '">
										<div class="delete-label">Deactivate this Announcement?</div>
										<div class="delete-yes-no" onclick="deleteAccount(\'' . $listAnnouncementValue['announce_idPK'] . '\', \'deleteAnnouncement\');">Yes</div>
										<div class="delete-yes-no" onclick="popupDeleteHide(\'' . $listAnnouncementValue['announce_idPK'] . '\');">No</div>
									</div>
								</div>';
			}
			else {
				$edButton = '&nbsp;&nbsp;<img src="' . DIR_IMAGES . 'icon/pencil_d.png" border="0" title="Edit"/>&nbsp;&nbsp;<img src="' . DIR_IMAGES . 'icon/recyclebin_d.png" title="Delete" border="0" />
						 	 &nbsp;<img src="' . DIR_IMAGES . 'icon/view.png" title="View" border="0" onclick="popupRequest(\'show\', \'ViewAnnouncement\', \'' . $strAccCourse . '\', \'390\', \'500\', \'' . $listAnnouncementValue['announce_idPK'] . '\');"/>';
			
			}
			$TEMP->set_var(array('announce_id' 		=> $listAnnouncementValue['announce_idPK'],
								 'announce_title' 	=> $listAnnouncementValue['announce_title'],
								 'numbering'		=> $numCount,
								 'bgcolor'			=> $bgcolor,
								 'ed_button'		=> $edButton
								));
								
			$TEMP->parse('announcementRow', 'announcements', true);
			$bgcolor = ($bgcolor == LOOPING_F0F) ? LOOPING_FFF : LOOPING_F0F;
			$numCount++;
		}
	}
	else {
		$TEMP->set_var(array('announce_id' 		=> '',
							 'announce_title' 	=> '',
							 'numbering'		=> '',
							 'bgcolor'			=> '',
							 'ed_button'		=> '',
							));
	}
	
	$TEMP->set_var(array('search' 			=> $search,
						 'pagination'		=> $pagination,
						 'results'			=> "<strong>" . $getListAnnouncementCount . "</strong> results",
						 'urlPage'			=> $urlPage,
						 'dean_sub_menu'	=> $pageLib->deanSubMenu(DIR_IMAGES),
						));
?>